<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>奖金列表</title>

    <link rel="stylesheet" href="http://cdn.viptool.cn/lib/bootstrap/3.3.5/css/bootstrap.min.css">
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="http://cdn.viptool.cn/lib/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="http://cdn.viptool.cn/lib/animate.css/2.1.1/animate.min.css" rel="stylesheet">
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
    <link href="http://cdn.viptool.cn/lib/switchery/0.8.2/switchery.min.css" rel="stylesheet"/>
    <link href="http://cdn.viptool.cn/lib/bootstrap-daterangepicker/2.1.25/daterangepicker.min.css" rel="stylesheet">
    <link href="../../resource/lib/imageview/css/imageviewer.css" rel="stylesheet"/>

    <style type="text/css">
        .hr-line-dashed {
            margin: 10px 0;
            height: 1px;
            border-top: 1px dashed #e7eaec;
            background-color: #fff;
            color: #fff;
        }

        .city-picker-selector select {

        }

        .daterangepicker {
            z-index: 999999999 !important;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight tooltip-demo">
    <!--search-->
    <form role="form" id="searchForm" class="search-panel" method="get" th:object="${condition}">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <div class="form-inline">
                            <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="keyword">代理商：</label>
                                <input type="text" class="form-control input-sm mb10" id="keyword" th:value="*{keyword}"
                                       name="keyword" placeholder="手机号/姓名/昵称" style="width: 156px;"/>
                            </div>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="keyword">奖金类型：</label>
                                <select class="form-control input-sm" name="rebateType" id="rebateType">
                                    <option value="-1">所有</option>
                                    <option th:each="type:${rebateTypeList}" th:value="${type.code}"
                                            th:text="${type.desc}"
                                            th:selected="${type.code}==*{rebateType}"></option>
                                </select>
                            </div>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="keyword">结算状态：</label>
                                <select class="form-control input-sm" name="rebateStatus" id="rebateStatus">
                                    <option value="-1">所有</option>
                                    <option th:each="status:${rebateStatusList}" th:value="${status.code}"
                                            th:text="${status.desc}"
                                            th:selected="${status.code}==*{rebateStatus}"></option>
                                </select>
                            </div>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="keyword">订单号：</label>
                                <input type="text" class="form-control input-sm mb10" id="orderId"
                                       th:value="*{orderId}" name="orderId" placeholder="订单号" style="width: 156px;"/>
                            </div>
                        </div>
                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="createTimePick">获得时间：</label>
                                <input type="text" class="form-control input-sm mb10 data-range-pick"
                                       id="createTimePick" name="createTimePick" start-element="#beginTime"
                                       end-element="#endTime" placeholder="开始时间-结束时间" style="width: 277px;"/>
                                <input type="hidden" th:value="*{beginTime}" id="beginTime" name="beginTime"/>
                                <input type="hidden" th:value="*{endTime}" id="endTime" name="endTime"/>
                            </div>
                            <div class="form-group m-r-sm">
                                <button type="button" onclick="tempRebateHandler.search(1)"
                                        class="btn btn-primary btn-sm m-b-none searchBtn">筛选
                                </button>
                                <button type="button" onclick="tempRebateHandler.searchAll()"
                                        class="btn btn-primary btn-sm m-b-none">显示全部
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->

    <!--list-->
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div class="tabs-container">
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body">
                                <table class="table table-bordered table-hover table-center">
                                    <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>账户</th>
                                        <th>类型</th>
                                        <th>最终金额</th>
                                        <th>初始金额</th>
                                        <th>添加时间</th>
                                        <th>结算状态</th>
                                        <th>预结算</th>
                                        <th>订单号</th>
                                        <th>描述</th>
                                        <th>贡献人</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <!--/*@thymesVar id="row" type="com.shengtang.stagent.data.entity.TempRebatesPO"*/-->
                                    <tr th:each="row,index:${list}">
                                        <td th:text="${row.rebateId}">123123</td>
                                        <td>
                                            <span th:text="|${row.user.realName}(${row.user.userLevelPO.levelName})|">王明(大区经理)</span>
                                            <br/>
                                            <span th:text="${row.user.username}">17678767675</span>
                                            <br/>
                                            <span th:text="${row.user.idcardNo}">33098988787676</span>
                                        </td>
                                        <td th:text="${row.rebateType.desc}">1211</td>
                                        <td><span th:text="${row.finalMoney}"></span></td>
                                        <td th:text="${row.flowMoney}">1211</td>
                                        <td th:text="${#temporals.format(row.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                        <td th:switch="${row.status.code}">
                                            <span th:case="0" class="color-primary"
                                                  th:text="${row.status.desc}">待结算</span>
                                            <span th:case="1" class="color-success"
                                                  th:text="${row.status.desc}">已结算</span>
                                            <span th:case="2" class="color-danger"
                                                  th:text="${row.status.desc}">结算前作废</span>
                                            <span th:case="*" class="color-primary" th:text="${row.status.desc}"></span>
                                        </td>
                                        <td th:text="${#temporals.format(row.toSettleTime,'yyyy-MM-dd')}"></td>
                                        <td th:text="${row.orderId}"></td>
                                        <td th:text="${row.rebateDesc}"></td>
                                        <td>
                                            <span th:text="${row.contribDepth}"></span>级
                                            (<span th:text="${row.contribLevelName}"></span>)
                                        </td>
                                        <td>
                                            <button onclick="tempRebateHandler.optLog('123')"
                                                    th:onclick="|tempRebateHandler.optLog('${row.rebateId}')|"
                                                    type="button"
                                                    class="btn btn-white btn-xs m-b-none">查看日志
                                            </button>

                                            <th:block th:if="${hasDeductRebateFunction}">
                                            <button onclick="tempRebateHandler.deduct('123')"
                                                    th:onclick="|tempRebateHandler.showDeduct('${row.rebateId}','${row.finalMoney}')|"
                                                    th:if="${row.status.code}==0"
                                                    type="button"
                                                    class="btn btn-xs m-b-none btn-warning">扣除奖金
                                            </button>
                                            </th:block>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <p style="float: left; margin: 20px 0;">
                                    共<span th:text="${totalRecords}"></span>条记录，当前第<span th:text="${pageIndex}"></span>/<span
                                        th:text="${totalPages==0?1:totalPages}"></span>，每页20条记录
                                </p>
                                <ul style="float: right;" class="pagination pagination-split">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="bind_modal" class="modal-content-tag">
    <form id="saveForm">
        <input type="hidden" id="rebateId"/>
        <div class="form-horizontal" style="width: 419px;">
            <div class="form-group form-inline">
                <label class="col-sm-3 control-label">总金额：</label>
                <div class="col-sm-9">
                    <input id="finalMoney" class="form-control" style="border:0px;background-color: #fff;"
                           readonly="readonly"/>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group form-inline">
                <label class="col-sm-3 control-label">*扣除：</label>
                <div class="col-sm-9">
                    <input placeholder="" id="deductMoney" class="form-control only-num" style="width: 120px;"/>
                </div>
            </div>
        </div>
    </form>
</div>

<!--基础框架js-->
<script src="http://cdn.viptool.cn/lib/jquery/2.2.4/jquery.min.js"></script>
<script src="http://cdn.viptool.cn/lib/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316}"></script>
<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>

<script src="http://cdn.viptool.cn/lib/moment.js/2.19.2/moment.min.js"></script>
<script src="../../resource/hotui/js/plugins/datetimepick/js/daterangepicker.js"
        th:src="@{/resource/hotui/js/plugins/datetimepick/js/daterangepicker.js}"></script>
<script src="http://cdn.viptool.cn/lib/switchery/0.8.2/switchery.min.js"></script>

<script src="../../resource/lib/cityPicker/citydata.min.js"></script>
<script src="../../resource/lib/cityPicker/cityPicker-2.0.3.js"></script>

<script src="../../resource/lib/imageview/js/imageviewer.min.js"></script>

<script src="../../js/stagent.uri.constant.js"></script>

<script type="text/javascript" th:inline="javascript">
    const pageIndex = /*[[${pageIndex}]]*/  1;
    const totalPages = /*[[${totalPages}]]*/  0;
    const pageUri = /*[[@{/tempRebate/list}]]*/  "";
    const tempRebateLogUri = /*[[@{/tempRebate/logs}]]*/  "temp_rebate_log.html";
</script>


<script src="https://cdn.bootcss.com/Mock.js/1.0.0/mock-min.js"></script>

<script>
    var checkModal = $("#bind_modal").modal("扣除奖金", function () {
        tempRebateHandler.deduct()
    });

    $(function () {
        //初始化分页
        var pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);

        pageinate.init(function (p) {
            tempRebateHandler.search(p);
        });
        $(document).keyup(function (event) {
            if (event.keyCode == 13) {
                $(".searchBtn").trigger("click");
            }
        });
    });

    var tempRebateHandler = {
        search: function (pageIndex) {
            $("input[name=pageIndex]").val(pageIndex);
            $("#searchForm").submit();
        },
        searchAll: function () {
            window.location.href = pageUri;
        },
        optLog: function (rebateId) {
            hot.iframeModal(tempRebateLogUri + '?rebateId=' + rebateId, '880px', '600px', "变动日志");
        },
        showDeduct: function (rebateId, finalMoney) {
            checkModal.show(function () {
                $('#finalMoney').val(finalMoney);
                $("#rebateId").val(rebateId);
            });
        },
        deduct: function () {
            var param = {
                rebateId: $('#rebateId').val(),
                deductMoney: $('#deductMoney').val()
            };
            if (param.deductMoney === '') {
                hot.tip.error('请输入扣除金额');
                return false;
            }
            hot.ajax('/tempRebate/deduct', param, function (ret) {
                hot.loading.close();
                if (ret.resultCode === 2000) {
                    hot.tip.success('扣除成功');
                    setTimeout(function () {
                        window.location.href = window.location.href;
                    }, 800);
                }
                else {
                    hot.tip.error('扣除失败');
                }
            }, function () {
            }, "post");
        }
    };
</script>
</body>
</html>
